﻿@inherits LayoutComponentBase
<MudThemeProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<div class="page">
    <div class="sidebar">
        <NavMenu @ref="navMenu" OnValueChanged="@OnValueChanged" />
    </div>

    <main>
        @*<div class="top-row px-4">
            <a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
        </div>*@

        <MudAppBar Color="Color.Primary" Fixed="false" Dense="true">
            <MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="CollapseNavMenu" />
            <MudSpacer />
            <MudIconButton Icon="@Icons.Material.Filled.FavoriteBorder" Color="Color.Inherit" Edge="Edge.End" />
            <MudIconButton Icon="@Icons.Material.Filled.MoreVert" Color="Color.Inherit" Edge="Edge.End" />
        </MudAppBar>

        @using IotClientApp.Client.Pages.Breadcrumbs
        <MyBreadcrumbs Title="@MenuTitle" Href="@MenuUrl" @ref="myBreadcrumbs"></MyBreadcrumbs>
        <article class="content px-4">
            @Body
        </article>
    </main>
</div>
@code{
    private NavMenu navMenu;
    private void CollapseNavMenu()
    {
        navMenu.ToggleNavMenu();
    }
    private string MenuTitle = "";
    private string MenuUrl = "";
    MyBreadcrumbs myBreadcrumbs;
    private void OnValueChanged(string val)
    {
        Console.WriteLine(val);
        var menus = val.Split("_");
        MenuTitle = menus[1];
        MenuUrl = menus[0];
        myBreadcrumbs.UpdateItems();
    }
}
